<template>
  <div class="app">
    <van-nav-bar title="长沙黑马程序员" left-text="返回" fixed left-arrow @click-left="onClickLeft"/>

    <transition name="app">
      <!-- 保存状态 把请求缓存  component :is -->
      <keep-alive>
        <router-view/>
      </keep-alive>
    </transition>

    <van-tabbar v-model="active">
      <van-tabbar-item icon="home-o" to="/home">首页</van-tabbar-item>
      <van-tabbar-item icon="user-o" to="/member">会员</van-tabbar-item>
      <van-tabbar-item icon="shopping-cart-o" to="/cart" :info="getAllCount">cart</van-tabbar-item>
      <van-tabbar-item icon="search" to="/search">search</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      active: 0
    };
  },
  methods: {
    onClickLeft() {
      // console.log(this.$router)
      this.$router.go(-1);
    }
  },
  computed: {
    ...mapGetters(["getAllCount"])

    // getAllCount(){
    //   return this.$store.getters.getAllCount
    // }
  }
};
</script>

<style lang="less">
.app {
  padding-top: 46px;
  padding-bottom: 50px;
  overflow-x: hidden;
  .app-enter {
    transform: translateX(100%);
  }
  .app-leave-to {
    transform: translateX(-100%);
    position: absolute;
    left: -200%;
  }

  .app-enter-active,
  .app-leave-active {
    transition: all 0.3s ease;
  }
  .van-nav-bar--fixed {
    z-index: 9999 !important;
  }
}
</style>
